package wumpus;

public class Cell {
	private final boolean[] percepts = new boolean[5];
	private Wumpus wumpus;
	private Hole hole;
	
	public boolean addWumpus() {
		if (this.hasHole() || this.hasGold()) return false;
		this.wumpus = new Wumpus();
		return true;
	}
	
	public boolean addHole() {
		if(this.hasGold()|| this.hasWumpus()) return false;
		this.hole = new Hole();
		return true;
	}
	
	public boolean addGold() {
		if(this.hasHole() || this.hasWumpus()) return false;
		this.setGlitter(true);
		return true;
	}
	
	public boolean hasGold() {
		return this.percepts[2];
	}
	
	public boolean hasHole() {
		if(this.hole == null) return false;
		else return true;
	}
	
	public boolean hasWumpus() {
		if(this.wumpus == null) return false;
		else return true;
	}
	/**
	 * Call hasWumpus() method first to make sure you have a wumpus
	 * in the cell.
	 * @return true if it is alive in this cell, false if not.
	 */
	public boolean isWumpusAlive() {
		return this.wumpus.isAlive();
	}
	
	public boolean killWumpus() {
		if(this.wumpus.kill()) return true;
		else return false;
	}
	
	public void setSmell(boolean isTrue) {
		percepts[0] = isTrue;
	}
	
	public void setBreeze(boolean isTrue) {
		percepts[1] = isTrue;
	}
	
	public void setGlitter(boolean isTrue) {
		percepts[2] = isTrue;
	}
	
	public void setHitWall(boolean isTrue) {
		percepts[3] = isTrue;
	}
	
	public void setScream(boolean isTrue) {
		percepts[4] = isTrue;
	}
	
	public void printPrecepts() {
		for(int i = 0; i < percepts.length; i++) {
			if(percepts[i]) System.out.println("    " + WumpusConstants.getPerceptString(i));
		}
	}
	
	public void printCell() {
			System.out.println("==========================================="); 
			this.printPrecepts();
			System.out.println("==========================================="); 
	}
	
	

}
